package com.zkn.component.office.excel.handler;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import com.zkn.component.office.excel.annotation.ExcelDataList;

/**
 * ExcelDataList Annotation Handler
 * @author frank.su
 * @date 2017/08/01
 *
 */
public class ExcelDataListHandler {
	
	public static List<List<?>>  parseExcelDataList(Object obj) throws Exception{
		List<List<?>> dataList = new ArrayList<List<?>>();
		
		Field[] fields = obj.getClass().getDeclaredFields();
		for (Field field : fields) {
			ExcelDataList excelDataList = field.getAnnotation(ExcelDataList.class);
			field.setAccessible(true);
			if(excelDataList != null && field.getType().isAssignableFrom(List.class)){
				dataList.add((List<?>) field.get(obj));
			}
		}
		
		return dataList;
	}
}